{include file="index/_meta" /}
    <title>地址列表</title>
</head>
<body>
<div id="app">
    <van-nav-bar
            title="地址列表"
            left-text="返回"
            left-arrow
            @click-left="window.history.back();"
    ></van-nav-bar>

    <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
        <van-address-list
                :list="addressList"
                default-tag-text="默认"
                @add="onAdd"
                @edit="onEdit"
        ></van-address-list>
    </van-pull-refresh>
</div>
<script>
    new Vue({
        el: "#app",
        data(){return{
            addressList: [],
            isLoading: false,
        }},
        created(){
            this.getUserAddress()
        },
        methods:{
            // 获取地址列表
            getUserAddress() {
                let that = this
                axios.post("{:url('user/getHarvestAddress')}").then(function (ret) {
                    that.addressList = ret.data.data
                })
            },
            onRefresh(){
                this.getUserAddress()
                this.isLoading = false
            },
            // 添加
            onAdd() {
                window.location.href = "{:url('user/address_create')}";
            },
            // 编辑
            onEdit(item) {
                window.location.href = "{:url('user/address_create')}?id="+item.id;
            },
        },
    })
</script>
</body>
</html>
